package com.heima.wemedia.controller.v1;

import com.heima.api.wemeida.WmMaterialControllerApi;
import com.heima.common.constants.wemedia.WemediaContans;
import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WmMaterialDto;
import com.heima.wemedia.service.MaterialService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@RestController
@RequestMapping("/api/v1/material")
public class WmMaterialController implements WmMaterialControllerApi {
    @Autowired
    private MaterialService materialService;
    @Autowired
    private MaterialService wmMaterialService;
        @PostMapping("/upload_picture")//图片上传
    @Override
    public ResponseResult upLoadFile(MultipartFile multipartFile) {
        return materialService.upLoadFile(multipartFile);
    }
    @RequestMapping("/list")
    @Override
    public ResponseResult findList(@RequestBody  WmMaterialDto dto) {
        return materialService.findList(dto);
    }
    @GetMapping("/del_picture/{id}")
    @Override //删除图片
    public ResponseResult delPicture(@PathVariable("id")Integer id) {
        return wmMaterialService.delPicture(id);
    }
    @GetMapping("/cancel_collect/{id}")
    @Override //取消收藏
    public ResponseResult cancleCollectionMaterial(@PathVariable("id") Integer id) {
        return wmMaterialService.updateStatus(id, WemediaContans.CANCEL_COLLECT_MATERIAL);
    }
    @GetMapping("/collect/{id}")
    @Override //收藏图片
    public ResponseResult collectionMaterial(@PathVariable("id") Integer id) {
        return wmMaterialService.updateStatus(id, WemediaContans.COLLECT_MATERIAL);
    }
}
